tblIgnoreFacingList = {
	"Shan'ze Cloudrunner";
	"Weak Spot";
	"Great White Plainshawk";
	"The Direglob";
	"Aeosera";
}
function AutoFacing()
	if ccrPlayerIsMoving() then return end
	if ccrValidTarget()
	and Target
	and Player:CanAttack(Target)
	and (Last_Facing == nil or GetTime()-Last_Facing > 0.25)
	then
		local vStopScript = false
		for i = 0, # tblIgnoreFacingList do
			if ccrTargetName() == tblIgnoreFacingList[i] then vStopScript = true end
		end
		
		if vStopScript then return end

		if not IsFacing()
		and not vStopScript
		then
			--[[X, Y, Z = Player:GetLocation()
			local Rotation = GetRotationBetweenPoints(X, Y, Z, Target:GetLocation())
			Rotation = Normalize(Rotation)
			InstantFace(Rotation)]]
			local X1, Y1 = Player:GetLocation()
			local X2, Y2 = Target:GetLocation()
			local Angle = rad(atan2(Y2 - Y1, X2 - X1))
			Angle = Normalize(Angle)
			InstantFace(Angle)
			Last_Facing = GetTime()
			TurnLeftStop();
		end
		--Target:Face()
	end
end
function Normalize (Rotation) return Rotation % (math.pi * 2); end
function InstantFace (Rotation) WriteFloat(ReadInt(Player:GetPointer() + 0xEC) + 0x20, Rotation % (math.pi * 2)); TurnLeftStart(); TurnLeftStop(); TurnLeftStop(); TurnLeftStop(); end
function IsFacing() 
	local X1, Y1 = Player:GetLocation()
	local X2, Y2 = Target:GetLocation()
	local Angle = rad(atan2(Y2 - Y1, X2 - X1))
	return abs(select(4, Player:GetLocation()) - Angle) < 0.1;
end

--[[
--function InstantFace (Rotation) WriteFloat(ReadInt(Player:GetPointer() + 0xE4) + 0x20, Rotation); TurnLeftStart(); TurnLeftStop(); end
function InstantFace (Rotation) WriteFloat(ReadInt(Player:GetPointer() + 0xE4) + 0x20, Rotation % (math.pi * 2)); TurnLeftStart(); TurnLeftStop(); TurnLeftStop(); TurnLeftStop(); end

function QuickLeft()
	Angle = select(4, Player:GetLocation()) + (math.pi /2)
	if InstantFace(Angle) then return true end;
end
function QuickRight()
	Angle = select(4, Player:GetLocation()) - (math.pi /2)
	if InstantFace(Angle) then return true end;
end
function QuickBehind()
	Angle = select(4, Player:GetLocation()) + math.pi
	if InstantFace(Angle) then return true end;
end

function InstantFace(Angle)
	local WoWVer = select(4, GetBuildInfo())
	if WoWVer == 50100 then
		WriteFloat(Player:GetPointer() + 0x7F8, Angle % (math.pi * 2));
		if not ccrPlayerIsMoving() then SendMovementUpdate() end
		return true;
	end
end
function ExactFace()
	if Target
	and Target:Exists()
	and not Target:IsDead()
	then
		local X1, Y1 = Player:GetLocation()
		local X2, Y2 = Target:GetLocation()
		local Angle = rad(atan2(Y2 - Y1, X2 - X1))
		InstantFace(Angle)
	end
end
function SendMovementUpdate()
	local Address = GetModuleBase() + 0x4564D0;
	local CMovement = ReadInt(Player:GetPointer() + 0xE4);
	local Timestamp = ReadInt(AssembleAndExecute("mov eax, " .. GetModuleBase() + 0x4678B0 .. "; call eax;") + 0x128);
	AssembleAndExecute("mov eax, " .. Player:GetMovementFlags() .. "; push eax; mov eax, " .. Timestamp .. "; push eax; push 1; mov ecx, " .. CMovement .. "; mov eax, " .. Address .. "; call eax")
end
]]--